package com.mf.all.config;

import cn.dev33.satoken.stp.StpInterface;

import cn.dev33.satoken.stp.StpUtil;
import com.mf.all.emuns.EnumBaseParams;
import com.mf.all.entity.dto.DtoPermission;
import com.mf.all.entity.dto.DtoRole;
import com.mf.all.service.ServicePermission;
import com.mf.all.service.ServiceRole;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * Created by Luke on 2025/3/7 16:12.
 */
@Component
public class ConfigSaToken implements StpInterface {
    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        final Object permissions = StpUtil.getSession().get(EnumBaseParams.permissions.name());
        if (permissions instanceof List<?>) {
            return (List<String>) permissions;
        }
        return new ArrayList<>();
    }

    /**
     * 根据账号id查询角色集合
     *
     * @param loginId 账号id
     */
    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        final Object roleList = StpUtil.getSession().get(EnumBaseParams.roles.name());
        if (roleList instanceof List<?>) {
            return (List<String>) roleList;
        }
        return new ArrayList<>();
    }
}
